﻿@model ScmCostactualViewModel
@{
    Layout = null;
    ViewBag.Title = "费用使用-审批";
    int num = 1;
}
<script type="text/javascript">
 function sumamount(i)
 {
     debugger;
        var amount = "TheCostActualList[" + i + "].Ca_Amount";
        
        var Deductamount = "TheCostActualList[" + i + "].Ca_Deduct";
        var Allamount = "TheCostActualList[" + i + "].Ca_ActualAmount";
        var Vamount = $(document.getElementsByName(amount)).val()
       
        var VDeductamount = $(document.getElementsByName(Deductamount)).val()
      
        if (Vamount == null || Vamount == "") {
            Vamount = 0;
        }
        if (VDeductamount == null || VDeductamount == "") {
            VDeductamount = 0;
        }
        var  VAllamount = parseFloat(Vamount)-parseFloat(VDeductamount);
       
        $(document.getElementsByName(Allamount)).val(VAllamount.toString());
        onload();
       
    }
</script>
<style type="text/css">
    .tr_hj td {
        font-weight: 600;
        text-align: center;
    }
</style>

<form method="post" action="@Url.Action("CostActualAuditData", "ScmCostActual")" class="pageForm required-validate" onsubmit="return validateCallback(this, dialogAjaxDone)">
    <div class="pageContent">
         <div class="pageFormContent" layouth="60">
             <dl>
                <dt style="text-align:right">施工单位：</dt>
                <dd>
                    @Html.TextBoxFor(model => model.TheScmCostactualmainInfo.Cam_ID, new { @type="hidden"})
                    @Html.TextBoxFor(model => model.TheScmCostactualmainInfo.Cam_ConstructionID, new { @type="hidden"})
                    @Html.TextBoxFor(model => model.TheScmCostactualmainInfo.Cam_ConstructionName) </dd>
            </dl>
            <dl>
                <dt style="text-align:right">标段：</dt>
                <dd>
                @Html.TextBoxFor(model => model.TheScmCostactualmainInfo.Cam_Section)</dd>
            </dl>
            <dl>
                <dt style="text-align:right">上报时间：</dt>
                <dd>
                     @Html.TextBoxFor(model => model.TheScmCostactualmainInfo.Cam_ReportTime,
                     new {Value = Model.TheScmCostactualmainInfo.Cam_ReportTime.ToString("yyyy-MM-dd") })
            </dl>
            <dl>
                <dt style="text-align:right">年份：</dt>
                <dd>
                   @Html.TextBoxFor(model => model.TheScmCostactualmainInfo.Cam_YearMonth,
                    new { format = "yyyy-MM", Value = Model.TheScmCostactualmainInfo.Cam_YearMonth.ToString("yyyy-MM") }) </dd>
            </dl>
            <dl>
                <dt style="text-align:right">审批人：</dt>
                <dd>
                    @Html.TextBoxFor(model => model.TheScmAuditInfo.A_ManName)
                </dd>
            </dl>
            <dl>
                <dt style="text-align:right">审批时间：</dt>
                <dd>
                     @Html.TextBoxFor(model => model.TheScmAuditInfo.A_Time,
                              new { @class = "date", Value = Model.TheScmAuditInfo.A_Time.ToString("yyyy-MM-dd") })</dd>
            </dl>
            <dl>
                <dt style="text-align:right">审批：</dt>
                <dd>
                   @Html.DropDownListFor(model => model.TheScmAuditInfo.A_IsApproved, ViewBag.auList as IEnumerable<SelectListItem>)</dd>
            </dl>
            <dl class="nowrap">
                <dt style="text-align:right">审批意见：</dt>
                <dd>
                     @Html.TextBoxFor(model => model.TheScmAuditInfo.A_Opinion, new { @size="52"})
                </dd>
            </dl>
       
       <div class="divider"></div>
            <div class="tabs" currentindex="0" eventtype="click">
                <div class="tabsHeader">
                    <div class="tabsHeaderContent">
                        <ul>
                            <li><a href="javascript:;"><span>费用统计表</span></a></li>
                            @*<li><a href="javascript:;"><span>审批意见</span></a></li>*@
                        </ul>
                    </div>
                </div>
                <div class="tabsContent" style="height: 250px;">
                    <div>
                        <table class="list nowrap" width="100%" nowraptd="false">
                            <thead>
                                <tr>
                                     <th style="text-align:center"  type="text" name="TheCostActualList[#index#].itemInt" defaultval="#index#" size="1" fieldclass="digits">序号</th>
                                    <th style="text-align:center"  style="text-align:center" size="20" name="TheCostActualList[#index#].Ca_Item" fieldclass="required">凭证名目</th>
                                    <th style="text-align:center"  type="text" name="TheCostActualList[#index#].Ca_Amount" defaultval="0.0" size="12" fieldclass="number">金额</th>
                                    <th style="text-align:center" type="text" name="TheCostActualList[#index#].Ca_InvoiceDate" size="12">开票日期</th>
                                    <th style="text-align:center" type="text" name="TheCostActualList[#index#].Ca_InvoiceNumb" size="12">发票编号</th>
                                      <th style="text-align:center"  type="text" name="TheCostActualList[#index#].Ca_Deduct" size="12">扣除金额</th>
                                      <th style="text-align:center"  type="text" name="TheCostActualList[#index#].Ca_ActualAmount" size="12">实际金额</th>
                                      <th style="text-align:center"  type="text" name="TheCostActualList[#index#].Ca_Remark" size="12">备注</th>
                                    
                                </tr>
                            </thead>
                            <tbody>
                                  @for (int index = 0; index < Model.TheCostActualList.Count; index++)
                                {
                           
                                    <tr>
                                        <td style="text-align:center"> <input type="text" style="border:none;text-align:center" name="TheCostActualList[@index].itemInt" value=@num defaultVal="#index#" size="1" fieldClass="digits"></input></td>
                                        <td style="text-align:center"><input type="text" style="border:none;text-align:center" size="50" name="TheCostActualList[@index].Ca_Item"  value=@Model.TheCostActualList[index].Ca_Item width="200" fieldClass="required" ></input></td>
                                        <td style="text-align:center"><input type="text" style="border:none;text-align:right" size="12" defaultVal="0.0" width="80" fieldClass="number" name="TheCostActualList[@index].Ca_Amount" value=@Model.TheCostActualList[index].Ca_Amount  ></input></td>
                                         <td style="text-align:center"><input type="text" style="text-align:right" size="12" defaultVal="0.0" width="80" fieldClass="number" name="TheCostActualList[@index].Ca_InvoiceDate" value=@Model.TheCostActualList[index].Ca_InvoiceDate.ToString("yyyy-MM-dd")></input></td>
                                         <td style="text-align:center"><input type="text" style="text-align:right" size="12" defaultVal="0.0" width="80" fieldClass="number" name="TheCostActualList[@index].Ca_InvoiceNumb" value=@Model.TheCostActualList[index].Ca_InvoiceNumb  ></input></td>
                                        <td style="text-align:center"><input type="text" style="text-align:right" size="12" onkeyup="sumamount(@index);"  defaultVal="0.0" width="80" fieldClass="number" name="TheCostActualList[@index].Ca_Deduct" value=@Model.TheCostActualList[index].Ca_Deduct  ></input></td>
                                         <td style="text-align:center"><input type="text" style="text-align:right;" readonly="true" size="12" defaultVal="0.0"  fieldClass="number" name="TheCostActualList[@index].Ca_ActualAmount" value=@Model.TheCostActualList[index].Ca_Amount  ></input></td>
                                        <td style="text-align:center"><input type="text" style="text-align:center" size="12" name="TheCostPlanList[@index].Cp_Remark" value=@Model.TheCostActualList[index].Ca_Remark ></input></td>
                                       
                                    </tr>
                                    num++;
                                }
                                <tr>
                                    <td colspan="2" style="text-align:center"><h3>合计</h3></td>
                                     <td style="text-align:center"><input type="text" style="border:none;text-align:right;font-weight:bold;" size="12" defaultVal="0.0" width="80" fieldClass="number" name="Ca_Amount" value=""  ></input></td>
                                     <td></td>
                                     <td></td>
                                     <td style="text-align:center"><input type="text" style="border:none;text-align:right;font-weight:bold;" size="12" defaultVal="0.0" width="80" fieldClass="number" name="Ca_Deduct" value=""  ></input></td>
                                     <td style="text-align:center"><input type="text" style="border:none;text-align:right;font-weight:bold;" size="12" defaultVal="0.0" width="80" fieldClass="number" name="Ca_ActualAmount" value=""  ></input></td>
                                    <td></td>
                                </tr>
                             
                            </tbody>
                        </table>
                    </div>
                    <div>
                        <table class="table" width="100%" nowraptd="false">
                            <thead>
                                <tr>
                                    <th width="30">序号</th>
                                    <th width="110">审批部门</th>
                                    <th width="110">审批人</th>
                                    <th width="110">审批时间</th>
                                    <th width="110">审批</th>
                                    <th>审批意见</th>
                                </tr>
                            </thead>
                            <tbody>
                                <tr>
                                    <td>1</td>
                                    <td>施工单位1</td>
                                    <td>管理员</td>
                                    <td>2016-11-28</td>
                                    <td>审批通过</td>
                                    <td>2016年1月份安监费，请总监办领导审批</td>
                                </tr>
                                <tr>
                                    <td>2</td>
                                    <td>总监办</td>
                                    <td>管理员</td>
                                    <td>2016-12-02</td>
                                    <td>审批通过</td>
                                    <td>本次安监费符合实际情况，请安监部审批</td>
                                </tr>
                            </tbody>
                        </table>
                    </div>
                </div>
                <div class="tabsFooter">
                    <div class="tabsFooterContent"></div>
                </div>
            </div>
      </div>
        <div class="formBar">
            <ul>
                 <li>
                        <button type="submit" class="btn btn-sm">审批</button>
                    </li>
                <li>
                    <button type="button" class="close btn btn-default btn-sm">取消</button>
                </li>
            </ul>
        </div>

    </div>
</form>
<script type="text/javascript">
    $(document).ready(function () {
        onload();
     });
    function onload() {
        debugger;
        var Aamount = 0, AAddamount = 0, ADeductamount = 0, AAllamount = 0;
        for (var i = 0; i < @num -1; i++) {
            var amount = "TheCostActualList[" + i + "].Ca_Amount";

            var Deductamount = "TheCostActualList[" + i + "].Ca_Deduct";
            var Allamount = "TheCostActualList[" + i + "].Ca_ActualAmount";

            var Vamount = $(document.getElementsByName(amount)).val();

            var VDeductamount = $(document.getElementsByName(Deductamount)).val();
            var VAllamount = $(document.getElementsByName(Allamount)).val();
            if (Vamount == null || Vamount == "") {
                Vamount = 0;
            }

            if (VDeductamount == null || VDeductamount == "") {
                VDeductamount = 0;
            }
            if (VAllamount == null || VAllamount == "") {
                VAllamount = 0;
            }
            Aamount += parseFloat(Vamount);

            ADeductamount += parseFloat(VDeductamount) * (-1);
            AAllamount += parseFloat(VAllamount);
        }
        $(document.getElementsByName("Ca_Amount")).val(Aamount.toString());

        $(document.getElementsByName("Ca_Deduct")).val(ADeductamount.toString());
        $(document.getElementsByName("Ca_ActualAmount")).val(AAllamount.toString());
    }
</script>